package com.business.form.service;
import java.util.HashMap;
import java.util.List;
import java.util.Map; 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Service;
import com.business.form.po.FormParamsValueBean;
import com.business.base.BaseDao;
import com.business.base.Pager;
import com.system.database.DS;
import com.common.BeanUtil;
import com.alibaba.fastjson.JSON;
/**
 * @author jpx 
 * @version 1.0
 * @since 1.0
 */
@Transactional(rollbackFor={RuntimeException.class,Exception.class})
@Service("com.business.form.service.FormParamsValueService")
@DS("formDb")
public class FormParamsValueService {
	@Autowired
	private BaseDao baseDao; 
	/**
	 * 向TS_Form_ParamsValue表中插入一条记录
	 * @param entity
	 */
	 public void insert(Map<String, Object> model) {
		this.baseDao.save("form.formParamsValue.insert", model); 
	}
	/**
	 * 向TS_Form_ParamsValue表批量插入数据
	 * @param List<FormParamsValue>
	 */
	 public void batchInsert(List<Map<String, Object>> list) {
		for(Map<String, Object> model:list){
			this.baseDao.save("form.formParamsValue.insert", model);
		} 
	}
	 /**
	  * 根据主键删除TS_Form_ParamsValue表中一条记录
	  * @param paramsValueId paramsValueId
	  */
	public void delete(java.lang.String paramsValueId) {
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("paramsValueId",paramsValueId);
		this.baseDao.delete("form.formParamsValue.delete", paramMap); 
	}
	/**
	 * 更新TS_Form_ParamsValue表中一条记录(entity中为null字段不更新)
	 * @param entity
	 */
	public void update(Map<String, Object> model) {
		this.baseDao.update("form.formParamsValue.update", model); 
	}
	/**
	 * 批量更新TS_Form_ParamsValue表记录(entity中为null字段不更新)
	 * @param List<FormParamsValue>
	 */
	public void batchUpdate(List<Map<String, Object>> list) {
		for(Map<String, Object> model:list){
			this.baseDao.update("form.formParamsValue.update", model); 		
		}
	}
	/**
	 * 根据条件获取分页list
	 * @param paramMap
	 * @return
	 */
    public Pager<Map<String, Object>> selectPage(int pageIndex, int pageSize, Map<String, Object> paramMap) {
		Pager<Map<String, Object>> result = baseDao.selectListByPage(pageIndex, pageSize, "form.formParamsValue.select",paramMap);
		
		for (int i = 0; i < result.getList().size(); i++) {
			Map<String, Object> item = result.getList().get(i);
			item.put("IndexNumber", (pageIndex - 1) * pageSize + i + 1);
		}
		
		return result;
	}
     /**
     * 根据条件获取list
     * @param paramMap
     * @return
     */
    public List<Map<String, Object>> select(Map<String, Object> paramMap) { 
		return	this.baseDao.selectList("form.formParamsValue.select", paramMap);
	}
	public FormParamsValueBean getBeanByKeyId(java.lang.String paramsValueId){
		Map<String, Object> paramMap = new HashMap<String, Object>();
		paramMap.put("paramsValueId",paramsValueId);
		List<Map<String, Object>> list=select(paramMap);
		
		FormParamsValueBean bean=null;
		if(list.size()>0){
			bean = BeanUtil.convertBeanByMap(list.get(0), FormParamsValueBean.class);
		}
		
		return bean;
	}

}
